<%@ page import="com.zafu.dao.CartGoodsBean" %>
<%@ page import="com.zafu.entity.CartGoodsInfo" %>
<%@ page import="java.net.URLDecoder" %>
<%@ page import="com.zafu.entity.AddressInfo" %>
<%@ page import="com.zafu.dao.AddressBean" %><%--
  Created by IntelliJ IDEA.
  User: 86189
  Date: 2024/12/25
  Time: 11:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String address = request.getParameter("address");
    if(address != null && address.length() > 0)
        address = URLDecoder.decode(address, "UTF-8");

    String username = request.getParameter("username");
    if(username != null && username.length() > 0)
        username = URLDecoder.decode(username, "UTF-8");

    String user_phone = request.getParameter("user_phone");
    if(user_phone != null && user_phone.length() > 0)
        user_phone = URLDecoder.decode(user_phone, "UTF-8");

    // 处理 Integer 类型的 count 参数
    Integer chosen = null;
    String chosenParam = request.getParameter("chosen");
    if (chosenParam != null && chosenParam.length() > 0) {
        try {
            chosen = Integer.parseInt(chosenParam);
        } catch (NumberFormatException e) {
            // 如果转换失败，可以记录日志或抛出异常
            System.out.println("Invalid chosen: " + chosenParam);
        }
    }

    Integer id = null;
    String idParam = request.getParameter("id");
    if (idParam != null && idParam.length() > 0) {
        try {
            id = Integer.parseInt(idParam);
        } catch (NumberFormatException e) {
            // 如果转换失败，可以记录日志或抛出异常
            System.out.println("Invalid id: " + idParam);
        }
    }

    AddressInfo addressInfo = new AddressInfo(address, username, user_phone, chosen,id);
    //AddressInfo addressInfo = new AddressInfo("test","test","test",0,3);
    AddressBean bean = new AddressBean();
    out.println("插入成功");
    bean.Add(addressInfo);
%>